import React, { FC } from 'react'
import { Typography } from 'antd'
import { QuestionParagraphPropsType, QuestionParagraphDefaultProps } from './interface'
const { Paragraph } = Typography

const QuestionParagraph: FC<QuestionParagraphPropsType> = (props: QuestionParagraphPropsType) => {
    const { text = '', isCenter = false } = { ...QuestionParagraphDefaultProps, ...props }
    const textList = text.split('\n')
    return (
        <Paragraph style={{ textAlign: isCenter ? 'center' : 'start', marginBottom: '0' }}>
            {/* <span dangerouslySetInnerHTML={{ __html: resHTML }}></span> 不要使用  */}
            {textList.map((t, index) => {
                return (
                    <span key={index}>
                        {index > 0 && <br />}
                        {t}
                    </span>
                )
            })}
        </Paragraph>
    )
}
export default QuestionParagraph
